package com.crm.service.system.impl;

import com.crm.dto.LogPagePramDto;
import com.crm.mapper.system.LogMapper;
import com.crm.pojo.OperateLog;
import com.crm.result.PageResult;
import com.crm.service.system.LogService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LogServiceImpl implements LogService {
    @Autowired
    private LogMapper logMapper;

    @Override
    public void save(OperateLog log) {
        logMapper.add(log);

    }

    @Override
    public PageResult queryPage(LogPagePramDto dto) {
        PageHelper.startPage(dto.getPageNum(), dto.getPageSize());
        List<OperateLog> list = logMapper.queryPage(dto);
        Page<OperateLog> page = (Page<OperateLog>) list;
        return new PageResult(page.getTotal(), page.getResult());
    }

    @Override
    public void deleteLog(Integer operId) {
        logMapper.delete(operId);
    }
}
